package org.unidbfw.db.core;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.unidbfw.common.UniDBFWException;

public class DbRow
{

	protected Map<String, Object> data = null;
	
	public DbRow()
	{
		this.data = new HashMap<String, Object>();
	}
	
	public DbRow(Map<String, Object> data)
	{
		this.data = data;
	}
	
	public DbRow(String[] titles, Object[] data) throws UniDBFWException
	{
		if (titles.length != data.length)
		{
			throw new UniDBFWException("Number of titles should be equal to number of record columns");
		}
		this.data = new HashMap<String, Object>();
		for (int i = 0; i < titles.length; i++)
		{
			this.data.put(titles[i], data[i]);
		}
	}
	
	public Object getData(String title)
	{
		return data.get(title);
	}
	
	public Set<String> getTitles()
	{
		return data.keySet();
	}
	
}
